<html>
<head>
<style>
  .ace_editor {
    border: 0;
    width: auto;
    height: 100%;
    margin: 0;
    top:0;
    right:0;
    bottom:0;
    left:0;
    z-index: 10000;
    touch-action: none;
  }

  body {
    padding: 0px;
    margin: 0px;
    overflow: hidden;
    -ms-overflow-style: scrollbar;
  }
</style>
</head>
<body>
<textarea id="source">package com.sencha.gxt.explorer.client.forms;

import java.util.List;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.core.client.util.ToggleGroup;
import com.sencha.gxt.explorer.client.app.ui.ExampleContainer;
import com.sencha.gxt.explorer.client.model.Example.Detail;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.CssFloatLayoutContainer;
import com.sencha.gxt.widget.core.client.container.CssFloatLayoutContainer.CssFloatData;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.form.DateField;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.FormPanel.LabelAlign;
import com.sencha.gxt.widget.core.client.form.FormPanelHelper;
import com.sencha.gxt.widget.core.client.form.HtmlEditor;
import com.sencha.gxt.widget.core.client.form.Radio;
import com.sencha.gxt.widget.core.client.form.TextField;

public class AdvancedFormsExample implements IsWidget, EntryPoint {

  protected static final int MIN_HEIGHT = 480;
  protected static final int MIN_WIDTH = 720;

  private FramedPanel panel;

  @Override
  public Widget asWidget() {
    if (panel == null) {
      TextField firstName = new TextField();
      firstName.setAllowBlank(false);

      TextField lastName = new TextField();
      lastName.setAllowBlank(false);

      TextField company = new TextField();

      TextField email = new TextField();

      DateField birthday = new DateField();

      Radio radio1 = new Radio();
      radio1.setHeight(20);
      radio1.setBoxLabel("Yes");

      Radio radio2 = new Radio();
      radio2.setHeight(20);
      radio2.setBoxLabel("No");

      CssFloatLayoutContainer radios = new CssFloatLayoutContainer();
      radios.add(radio1, new CssFloatData(-1, new Margins(4, 0, 0, 0)));
      radios.add(radio2, new CssFloatData(-1, new Margins(4, 0, 0, 0)));

      ToggleGroup group = new ToggleGroup();
      group.add(radio1);
      group.add(radio2);

      HtmlEditor htmlEditor = new HtmlEditor();

      CssFloatLayoutContainer columns = new CssFloatLayoutContainer();
      columns.add(new FieldLabel(firstName, "First Name"), new CssFloatData(0.5, new Margins(0, 7, 0, 0)));
      columns.add(new FieldLabel(lastName, "Last Name"), new CssFloatData(0.5, new Margins(0, 0, 0, 8)));
      columns.add(new FieldLabel(company, "Company"), new CssFloatData(0.5, new Margins(0, 7, 0, 0)));
      columns.add(new FieldLabel(email, "Email"), new CssFloatData(0.5, new Margins(0, 0, 0, 8)));
      columns.add(new FieldLabel(birthday, "Birthday"), new CssFloatData(0.5, new Margins(0, 7, 0, 0)));
      columns.add(new FieldLabel(radios, "GXT User"), new CssFloatData(0.5, new Margins(0, 0, 0, 8)));

      VerticalLayoutContainer container = new VerticalLayoutContainer();
      container.add(columns, new VerticalLayoutData(1, -1, new Margins(15, 15, 0, 15)));
      container.add(new FieldLabel(htmlEditor, "Comment"), new VerticalLayoutData(1, 1, new Margins(0, 15, 0, 15)));

      panel = new FramedPanel();
      panel.setHeading("Advanced Forms");
      panel.add(container);
      panel.addButton(new TextButton("Cancel"));
      panel.addButton(new TextButton("Submit"));

      // need to call after everything is constructed
      List<FieldLabel> fieldLabels = FormPanelHelper.getFieldLabels(panel);
      for (FieldLabel fieldLabel : fieldLabels) {
        fieldLabel.setLabelAlign(LabelAlign.TOP);
      }
    }

    return panel;
  }

  @Override
  public void onModuleLoad() {
    new ExampleContainer(this)
        .setMinHeight(MIN_HEIGHT)
        .setMinWidth(MIN_WIDTH)
        .doStandalone();
  }

}
</textarea>

<script src="../../samples/ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
  var type = "{type}";
  if (type == ("{" + "type}")) {
    // something went wrong, use java as default
    type = "java";
  }
  var editor = ace.edit("source");
  var mode = "ace/mode/" + type;
  var theme = "ace/theme/chrome";
  var readOnly = true;
  editor.getSession().setMode(mode);
  editor.getSession().setUseWorker(false);
  editor.setTheme(theme);
  editor.setShowPrintMargin(false);
  editor.renderer.setShowGutter(true);
  editor.setHighlightActiveLine(false);
  editor.setDisplayIndentGuides(true);
  editor.setReadOnly(readOnly);
  editor.renderer.setPadding(10);
  editor.renderer.setScrollMargin(10, 10, 0, 0);
  editor.getSession().setOptions({
    tabSize: 8,
    useSoftTabs: true,
    useWrapMode: false,
  });
</script>
</body>
</html>